package com.ums.providerboot;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.session.data.redis.RedisFlushMode;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

//@EnableCircuitBreaker
@RefreshScope  //启用配置刷新
@EnableEurekaClient  //启用eureka client发现服务器
@EnableFeignClients  //启用feign client
@RestController
@SpringBootApplication
@EnableRedisHttpSession(redisFlushMode = RedisFlushMode.IMMEDIATE)
public class ProviderBootApplication {

    @Value("${env}")
    private String env = "default";
    @Value("${mode}")
    private String conf_model = "native";
    @Value("${db_user}")
    private String db_user;
    @Value("${db_pwd}")
    private String db_pwd;
    @Value("${db_url}")
    private String db_url;

    @GetMapping("get_env")
    public String env(){
        return String.format("配置模式:%s,当前的环境是:%s, 用户名:%s, 密码:%s, 连接:%s",
                conf_model, env, db_user, db_pwd, db_url);
    }

    public static void main(String[] args) {
        SpringApplication.run(ProviderBootApplication.class, args);
    }
}
